home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Doc / libfcntl.tex < prev    next >
LaTeX Document  |  1994-08-08  |  2.3 KB  |  [TEXT/R*ch]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: LaTeX Document (document/latex).

You can browse this item here: libfcntl.tex

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file LaTeX document, ASCII text, with CR line terminators default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[CR] default (weak)


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[R*ch]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 25 20 4d 61 6e 75 61 6c | 20 74 65 78 74 20 62 79 |% Manual| text by|
|00000010| 20 4a 61 61 70 20 56 65 | 72 6d 65 75 6c 65 6e 0d | Jaap Ve|rmeulen.|
|00000020| 5c 73 65 63 74 69 6f 6e | 7b 42 75 69 6c 74 2d 69 |\section|{Built-i|
|00000030| 6e 20 6d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |n module| \sectco|
|00000040| 64 65 7b 66 63 6e 74 6c | 7d 7d 0d 5c 62 69 6d 6f |de{fcntl|}}.\bimo|
|00000050| 64 69 6e 64 65 78 7b 66 | 63 6e 74 6c 7d 0d 5c 69 |dindex{f|cntl}.\i|
|00000060| 6e 64 65 78 69 69 7b 55 | 4e 49 58 7d 7b 66 69 6c |ndexii{U|NIX}{fil|
|00000070| 65 20 63 6f 6e 74 72 6f | 6c 7d 0d 5c 69 6e 64 65 |e contro|l}.\inde|
|00000080| 78 69 69 7b 55 4e 49 58 | 7d 7b 49 4f 20 63 6f 6e |xii{UNIX|}{IO con|
|00000090| 74 72 6f 6c 7d 0d 0d 54 | 68 69 73 20 6d 6f 64 75 |trol}..T|his modu|
|000000a0| 6c 65 20 70 65 72 66 6f | 72 6d 73 20 66 69 6c 65 |le perfo|rms file|
|000000b0| 20 63 6f 6e 74 72 6f 6c | 20 61 6e 64 20 49 4f 20 | control| and IO |
|000000c0| 63 6f 6e 74 72 6f 6c 20 | 6f 6e 20 66 69 6c 65 20 |control |on file |
|000000d0| 64 65 73 63 72 69 70 74 | 6f 72 73 2e 0d 49 74 20 |descript|ors..It |
|000000e0| 69 73 20 61 6e 20 69 6e | 74 65 72 66 61 63 65 20 |is an in|terface |
|000000f0| 74 6f 20 74 68 65 20 5c | 64 66 6e 7b 66 63 6e 74 |to the \|dfn{fcnt|
|00000100| 6c 28 29 7d 20 61 6e 64 | 20 5c 64 66 6e 7b 69 6f |l()} and| \dfn{io|
|00000110| 63 74 6c 28 29 7d 20 5c | 55 4e 49 58 20 72 6f 75 |ctl()} \|UNIX rou|
|00000120| 74 69 6e 65 73 2e 0d 46 | 69 6c 65 20 64 65 73 63 |tines..F|ile desc|
|00000130| 72 69 70 74 6f 72 73 20 | 63 61 6e 20 62 65 20 6f |riptors |can be o|
|00000140| 62 74 61 69 6e 65 64 20 | 77 69 74 68 20 74 68 65 |btained |with the|
|00000150| 20 5c 64 66 6e 7b 66 69 | 6c 65 6e 6f 28 29 7d 20 | \dfn{fi|leno()} |
|00000160| 6d 65 74 68 6f 64 20 6f | 66 20 61 0d 66 69 6c 65 |method o|f a.file|
|00000170| 20 6f 72 20 73 6f 63 6b | 65 74 20 6f 62 6a 65 63 | or sock|et objec|
|00000180| 74 2e 0d 0d 54 68 65 20 | 6d 6f 64 75 6c 65 20 64 |t...The |module d|
|00000190| 65 66 69 6e 65 73 20 74 | 68 65 20 66 6f 6c 6c 6f |efines t|he follo|
|000001a0| 77 69 6e 67 20 66 75 6e | 63 74 69 6f 6e 73 3a 0d |wing fun|ctions:.|
|000001b0| 0d 5c 72 65 6e 65 77 63 | 6f 6d 6d 61 6e 64 7b 5c |.\renewc|ommand{\|
|000001c0| 69 6e 64 65 78 73 75 62 | 69 74 65 6d 7d 7b 28 69 |indexsub|item}{(i|
|000001d0| 6e 20 6d 6f 64 75 6c 65 | 20 73 74 72 75 63 74 29 |n module| struct)|
|000001e0| 7d 0d 0d 5c 62 65 67 69 | 6e 7b 66 75 6e 63 64 65 |}..\begi|n{funcde|
|000001f0| 73 63 7d 7b 66 63 6e 74 | 6c 7d 7b 66 64 5c 2c 20 |sc}{fcnt|l}{fd\, |
|00000200| 6f 70 5c 6f 70 74 69 6f | 6e 61 6c 7b 5c 2c 20 61 |op\optio|nal{\, a|
|00000210| 72 67 7d 7d 0d 20 20 50 | 65 72 66 6f 72 6d 20 74 |rg}}. P|erform t|
|00000220| 68 65 20 72 65 71 75 65 | 73 74 65 64 20 6f 70 65 |he reque|sted ope|
|00000230| 72 61 74 69 6f 6e 20 6f | 6e 20 66 69 6c 65 20 64 |ration o|n file d|
|00000240| 65 73 63 72 69 70 74 6f | 72 20 5c 63 6f 64 65 7b |escripto|r \code{|
|00000250| 5c 76 61 72 7b 66 64 7d | 7d 2e 0d 20 20 54 68 65 |\var{fd}|}.. The|
|00000260| 20 6f 70 65 72 61 74 69 | 6f 6e 20 69 73 20 64 65 | operati|on is de|
|00000270| 66 69 6e 65 64 20 62 79 | 20 5c 63 6f 64 65 7b 5c |fined by| \code{\|
|00000280| 76 61 72 7b 6f 70 7d 7d | 20 61 6e 64 20 69 73 20 |var{op}}| and is |
|00000290| 6f 70 65 72 61 74 69 6e | 67 20 73 79 73 74 65 6d |operatin|g system|
|000002a0| 0d 20 20 64 65 70 65 6e | 64 65 6e 74 2e 20 20 54 |. depen|dent. T|
|000002b0| 79 70 69 63 61 6c 6c 79 | 20 74 68 65 73 65 20 63 |ypically| these c|
|000002c0| 6f 64 65 73 20 63 61 6e | 20 62 65 20 72 65 74 72 |odes can| be retr|
|000002d0| 69 65 76 65 64 20 66 72 | 6f 6d 20 74 68 65 20 6c |ieved fr|om the l|
|000002e0| 69 62 72 61 72 79 0d 20 | 20 6d 6f 64 75 6c 65 20 |ibrary. | module |
|000002f0| 5c 63 6f 64 65 7b 46 43 | 4e 54 4c 7d 2e 20 54 68 |\code{FC|NTL}. Th|
|00000300| 65 20 61 72 67 75 6d 65 | 6e 74 20 5c 63 6f 64 65 |e argume|nt \code|
|00000310| 7b 5c 76 61 72 7b 61 72 | 67 7d 7d 20 69 73 20 6f |{\var{ar|g}} is o|
|00000320| 70 74 69 6f 6e 61 6c 2c | 20 61 6e 64 0d 20 20 64 |ptional,| and. d|
|00000330| 65 66 61 75 6c 74 73 20 | 74 6f 20 74 68 65 20 69 |efaults |to the i|
|00000340| 6e 74 65 67 65 72 20 76 | 61 6c 75 65 20 5c 63 6f |nteger v|alue \co|
|00000350| 64 65 7b 30 7d 2e 20 20 | 57 68 65 6e 0d 20 20 69 |de{0}. |When. i|
|00000360| 74 20 69 73 20 70 72 65 | 73 65 6e 74 2c 20 69 74 |t is pre|sent, it|
|00000370| 20 63 61 6e 20 65 69 74 | 68 65 72 20 62 65 20 61 | can eit|her be a|
|00000380| 6e 20 69 6e 74 65 67 65 | 72 20 76 61 6c 75 65 2c |n intege|r value,|
|00000390| 20 6f 72 20 61 20 73 74 | 72 69 6e 67 2e 20 20 57 | or a st|ring. W|
|000003a0| 69 74 68 0d 20 20 74 68 | 65 20 61 72 67 75 6d 65 |ith. th|e argume|
|000003b0| 6e 74 20 6d 69 73 73 69 | 6e 67 20 6f 72 20 61 6e |nt missi|ng or an|
|000003c0| 20 69 6e 74 65 67 65 72 | 20 76 61 6c 75 65 2c 20 | integer| value, |
|000003d0| 74 68 65 20 72 65 74 75 | 72 6e 20 76 61 6c 75 65 |the retu|rn value|
|000003e0| 20 6f 66 20 74 68 69 73 | 0d 20 20 66 75 6e 63 74 | of this|. funct|
|000003f0| 69 6f 6e 20 69 73 20 74 | 68 65 20 69 6e 74 65 67 |ion is t|he integ|
|00000400| 65 72 20 72 65 74 75 72 | 6e 20 76 61 6c 75 65 20 |er retur|n value |
|00000410| 6f 66 20 74 68 65 20 72 | 65 61 6c 20 5c 63 6f 64 |of the r|eal \cod|
|00000420| 65 7b 66 63 6e 74 6c 28 | 29 7d 0d 20 20 63 61 6c |e{fcntl(|)}. cal|
|00000430| 6c 2e 20 20 57 68 65 6e | 20 74 68 65 20 61 72 67 |l. When| the arg|
|00000440| 75 6d 65 6e 74 20 69 73 | 20 61 20 73 74 72 69 6e |ument is| a strin|
|00000450| 67 20 69 74 20 72 65 70 | 72 65 73 65 6e 74 73 20 |g it rep|resents |
|00000460| 61 20 62 69 6e 61 72 79 | 0d 20 20 73 74 72 75 63 |a binary|. struc|
|00000470| 74 75 72 65 2c 20 65 2e | 67 2e 20 20 63 72 65 61 |ture, e.|g. crea|
|00000480| 74 65 64 20 62 79 20 5c | 63 6f 64 65 7b 73 74 72 |ted by \|code{str|
|00000490| 75 63 74 2e 70 61 63 6b | 28 29 7d 2e 20 54 68 65 |uct.pack|()}. The|
|000004a0| 20 62 69 6e 61 72 79 20 | 64 61 74 61 20 69 73 0d | binary |data is.|
|000004b0| 20 20 63 6f 70 69 65 64 | 20 74 6f 20 61 20 62 75 | copied| to a bu|
|000004c0| 66 66 65 72 20 77 68 6f | 73 65 20 61 64 64 72 65 |ffer who|se addre|
|000004d0| 73 73 20 69 73 20 70 61 | 73 73 65 64 20 74 6f 20 |ss is pa|ssed to |
|000004e0| 74 68 65 20 72 65 61 6c | 20 5c 63 6f 64 65 7b 66 |the real| \code{f|
|000004f0| 63 6e 74 6c 28 29 7d 0d | 20 20 63 61 6c 6c 2e 20 |cntl()}.| call. |
|00000500| 20 54 68 65 20 72 65 74 | 75 72 6e 20 76 61 6c 75 | The ret|urn valu|
|00000510| 65 20 61 66 74 65 72 20 | 61 20 73 75 63 63 65 73 |e after |a succes|
|00000520| 73 66 75 6c 20 63 61 6c | 6c 20 69 73 20 74 68 65 |sful cal|l is the|
|00000530| 20 63 6f 6e 74 65 6e 74 | 73 20 6f 66 0d 20 20 74 | content|s of. t|
|00000540| 68 65 20 62 75 66 66 65 | 72 2c 20 63 6f 6e 76 65 |he buffe|r, conve|
|00000550| 72 74 65 64 20 74 6f 20 | 61 20 73 74 72 69 6e 67 |rted to |a string|
|00000560| 20 6f 62 6a 65 63 74 2e | 20 20 49 6e 20 74 68 65 | object.| In the|
|00000570| 20 63 61 73 65 20 74 68 | 65 0d 20 20 5c 63 6f 64 | case th|e. \cod|
|00000580| 65 7b 66 63 6e 74 6c 28 | 29 7d 20 66 61 69 6c 73 |e{fcntl(|)} fails|
|00000590| 2c 20 61 6e 20 5c 63 6f | 64 65 7b 49 4f 45 72 72 |, an \co|de{IOErr|
|000005a0| 6f 72 7d 20 77 69 6c 6c | 20 62 65 20 72 61 69 73 |or} will| be rais|
|000005b0| 65 64 2e 0d 5c 65 6e 64 | 7b 66 75 6e 63 64 65 73 |ed..\end|{funcdes|
|000005c0| 63 7d 0d 0d 5c 62 65 67 | 69 6e 7b 66 75 6e 63 64 |c}..\beg|in{funcd|
|000005d0| 65 73 63 7d 7b 69 6f 63 | 74 6c 7d 7b 66 64 5c 2c |esc}{ioc|tl}{fd\,|
|000005e0| 20 6f 70 5c 2c 20 61 72 | 67 7d 0d 20 20 54 68 69 | op\, ar|g}. Thi|
|000005f0| 73 20 66 75 6e 63 74 69 | 6f 6e 20 69 73 20 69 64 |s functi|on is id|
|00000600| 65 6e 74 69 63 61 6c 20 | 74 6f 20 74 68 65 20 5c |entical |to the \|
|00000610| 63 6f 64 65 7b 66 63 6e | 74 6c 28 29 7d 20 66 75 |code{fcn|tl()} fu|
|00000620| 6e 63 74 69 6f 6e 2c 20 | 65 78 63 65 70 74 0d 20 |nction, |except. |
|00000630| 20 74 68 61 74 20 74 68 | 65 20 6f 70 65 72 61 74 | that th|e operat|
|00000640| 69 6f 6e 73 20 61 72 65 | 20 74 79 70 69 63 61 6c |ions are| typical|
|00000650| 6c 79 20 64 65 66 69 6e | 65 64 20 69 6e 20 74 68 |ly defin|ed in th|
|00000660| 65 20 6c 69 62 72 61 72 | 79 20 6d 6f 64 75 6c 65 |e librar|y module|
|00000670| 0d 20 20 5c 63 6f 64 65 | 7b 49 4f 43 54 4c 7d 2e |. \code|{IOCTL}.|
|00000680| 0d 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0d |.\end{fu|ncdesc}.|
|00000690| 0d 49 66 20 74 68 65 20 | 6c 69 62 72 61 72 79 20 |.If the |library |
|000006a0| 6d 6f 64 75 6c 65 73 20 | 5c 63 6f 64 65 7b 46 43 |modules |\code{FC|
|000006b0| 4e 54 4c 7d 20 6f 72 20 | 5c 63 6f 64 65 7b 49 4f |NTL} or |\code{IO|
|000006c0| 43 54 4c 7d 20 61 72 65 | 20 6d 69 73 73 69 6e 67 |CTL} are| missing|
|000006d0| 2c 20 79 6f 75 0d 63 61 | 6e 20 66 69 6e 64 20 74 |, you.ca|n find t|
|000006e0| 68 65 20 6f 70 63 6f 64 | 65 73 20 69 6e 20 74 68 |he opcod|es in th|
|000006f0| 65 20 43 20 69 6e 63 6c | 75 64 65 20 66 69 6c 65 |e C incl|ude file|
|00000700| 73 20 5c 63 6f 64 65 7b | 73 79 73 2f 66 63 6e 74 |s \code{|sys/fcnt|
|00000710| 6c 7d 20 61 6e 64 0d 5c | 63 6f 64 65 7b 73 79 73 |l} and.\|code{sys|
|00000720| 2f 69 6f 63 74 6c 7d 2e | 20 59 6f 75 20 63 61 6e |/ioctl}.| You can|
|00000730| 20 63 72 65 61 74 65 20 | 74 68 65 20 6d 6f 64 75 | create |the modu|
|00000740| 6c 65 73 20 79 6f 75 72 | 73 65 6c 66 20 77 69 74 |les your|self wit|
|00000750| 68 20 74 68 65 20 68 32 | 70 79 0d 73 63 72 69 70 |h the h2|py.scrip|
|00000760| 74 2c 20 66 6f 75 6e 64 | 20 69 6e 20 74 68 65 20 |t, found| in the |
|00000770| 5c 63 6f 64 65 7b 44 65 | 6d 6f 2f 73 63 72 69 70 |\code{De|mo/scrip|
|00000780| 74 73 7d 20 64 69 72 65 | 63 74 6f 72 79 2e 0d 0d |ts} dire|ctory...|
|00000790| 45 78 61 6d 70 6c 65 73 | 20 28 61 6c 6c 20 6f 6e |Examples| (all on|
|000007a0| 20 61 20 53 56 52 34 20 | 63 6f 6d 70 6c 69 61 6e | a SVR4 |complian|
|000007b0| 74 20 73 79 73 74 65 6d | 29 3a 0d 0d 5c 62 63 6f |t system|):..\bco|
|000007c0| 64 65 5c 62 65 67 69 6e | 7b 76 65 72 62 61 74 69 |de\begin|{verbati|
|000007d0| 6d 7d 0d 69 6d 70 6f 72 | 74 20 73 74 72 75 63 74 |m}.impor|t struct|
|000007e0| 2c 20 46 43 4e 54 4c 0d | 0d 66 69 6c 65 20 3d 20 |, FCNTL.|.file = |
|000007f0| 6f 70 65 6e 28 2e 2e 2e | 29 0d 72 76 20 3d 20 66 |open(...|).rv = f|
|00000800| 63 6e 74 6c 28 66 69 6c | 65 2e 66 69 6c 65 6e 6f |cntl(fil|e.fileno|
|00000810| 28 29 2c 20 46 43 4e 54 | 4c 2e 4f 5f 4e 44 45 4c |(), FCNT|L.O_NDEL|
|00000820| 41 59 2c 20 31 29 0d 0d | 6c 6f 63 6b 64 61 74 61 |AY, 1)..|lockdata|
|00000830| 20 3d 20 73 74 72 75 63 | 74 2e 70 61 63 6b 28 27 | = struc|t.pack('|
|00000840| 68 68 6c 6c 68 68 27 2c | 20 46 43 4e 54 4c 2e 46 |hhllhh',| FCNTL.F|
|00000850| 5f 57 52 4c 43 4b 2c 20 | 30 2c 20 30 2c 20 30 2c |_WRLCK, |0, 0, 0,|
|00000860| 20 30 2c 20 30 29 0d 72 | 76 20 3d 20 66 63 6e 74 | 0, 0).r|v = fcnt|
|00000870| 6c 28 66 69 6c 65 2e 66 | 69 6c 65 6e 6f 28 29 2c |l(file.f|ileno(),|
|00000880| 20 46 43 4e 54 4c 2e 46 | 5f 53 45 54 4c 4b 57 2c | FCNTL.F|_SETLKW,|
|00000890| 20 6c 6f 63 6b 64 61 74 | 61 29 0d 5c 65 6e 64 7b | lockdat|a).\end{|
|000008a0| 76 65 72 62 61 74 69 6d | 7d 5c 65 63 6f 64 65 0d |verbatim|}\ecode.|
|000008b0| 0d 4e 6f 74 65 20 74 68 | 61 74 20 69 6e 20 74 68 |.Note th|at in th|
|000008c0| 65 20 66 69 72 73 74 20 | 65 78 61 6d 70 6c 65 20 |e first |example |
|000008d0| 74 68 65 20 72 65 74 75 | 72 6e 20 76 61 6c 75 65 |the retu|rn value|
|000008e0| 20 76 61 72 69 61 62 6c | 65 20 5c 63 6f 64 65 7b | variabl|e \code{|
|000008f0| 72 76 7d 20 77 69 6c 6c | 0d 68 6f 6c 64 20 61 6e |rv} will|.hold an|
|00000900| 20 69 6e 74 65 67 65 72 | 20 76 61 6c 75 65 3b 20 | integer| value; |
|00000910| 69 6e 20 74 68 65 20 73 | 65 63 6f 6e 64 20 65 78 |in the s|econd ex|
|00000920| 61 6d 70 6c 65 20 69 74 | 20 77 69 6c 6c 20 68 6f |ample it| will ho|
|00000930| 6c 64 20 61 20 73 74 72 | 69 6e 67 0d 76 61 6c 75 |ld a str|ing.valu|
|00000940| 65 2e 0d | |e.. | |
+--------+-------------------------+-------------------------+--------+--------+